﻿using IBLL;
using IDAL;
using MD5Hash;
using Model;

namespace BLL
{
    public class MemberBLL : IMemberBLL
    {
        public MemberBLL(IBase<Member> db)
        {
            Db = db;
        }

        public IBase<Member> Db { get; }

       
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="name"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public Member Login(string name, string pwd)
        {
            var m = Db.GetAll();
            Member s = m.Where(x => x.Name == name).FirstOrDefault();
            if (m == null)
            {
                s = new Member();
                s.Id = -1;
            }
            else 
            {
                if (s.Pwd!=pwd) 
                {
                    s = new Member();
                    s.Id = -2;
                }
            }
            return s;
        }
    }
}
